package a.f.d;

import a.c.ab;
import a.c.bb;
import a.c.d;
import a.c.e;
import a.c.k;
import a.c.q;
import a.c.w;
import a.f.d.a.ac;
import a.f.d.a.bc;
import a.f.d.a.hc;
import a.f.d.a.zb;
import a.f.o;

import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;

public class pb
  implements fb, zb
{
  private static final double a = 0.001D;
  private long b = 9223372036854775807L;
  protected k c;
  protected Object d;
  private boolean e;
  public static boolean f;
  
  public pb()
  {
    this(null);
  }
  
  public pb(Object paramObject)
  {
    this.d = paramObject;
  }
  
  public boolean a()
  {
    return this.e;
  }
  
  public void a(boolean paramBoolean)
  {
    this.e = paramBoolean;
  }
  
  public long b()
  {
    return this.b;
  }
  
  public void a(long paramLong)
  {
    this.b = paramLong;
  }
  
  public int a(o paramo, a.c.x paramx, ab paramab)
  {
    if (f.o == 0) {
      if (this.d != null) {
        return a(paramo, paramx, paramab, paramo.c(this.d));
      }
    }
    return a(paramo, paramx, paramab, null);
  }
  
  public int a(o paramo, a.c.x paramx, ab paramab, k paramk)
  {
    int n = f.o;
    int m = f.n;
    this.c = paramk;
    boolean bool = a();
    a.c.x localx1;
    a.c.n localn;
    if (bool)
    {
      localx1 = paramo.B();
      localn = paramo.C();
      if (m == 0) {}
    }
    else
    {
      localx1 = null;
      localn = null;
    }
    a.c.x localx2 = paramo.B();
    int i = a.a.m.a(paramo, localx2);
    a.i.z localz = new a.i.z(paramo, localx2);
    int j = 0;
    int k = 0;
    do
    {
      if (k >= i) {
        break;
      }
      localz.c(new Integer(k));
      a.i.n.a(this, "Make acyclic");
      a(paramo, paramab, localx1, localn);
      a.i.n.a(this, "Assign layers");
      j = Math.max(j, a(paramo, paramx));
      a.i.n.a(this, "done");
      k++;
      if (n != 0) {
        break label180;
      }
      if (m != 0) {
        break label178;
      }
    } while (m == 0);
    localz.g();
    if (n == 0)
    {
      paramo.a(localx2);
      label178:
      label180:
      if (n != 0) {
        break label202;
      }
      if (bool) {
        paramo.a(localn);
      }
    }
    else
    {
      paramo.a(localx1);
    }
    label202:
    return j;
  }
  
  private void a(o paramo, ab paramab, a.c.x paramx, a.c.n paramn)
  {
    int i = f.o;
    if (i == 0) {
      if (a())
      {
        if (i != 0) {
          break label40;
        }
        c(paramo, paramab, paramx, paramn);
        if (f.n == 0) {
          return;
        }
      }
    }
    label40:
    a(paramo, paramab);
  }
  
  private void c(o paramo, ab paramab, a.c.x paramx, a.c.n paramn)
  {
    int j = f.o;
    int i = f.n;
    if ((j != 0) || ((paramo.m() < 2) || (paramo.k() < 2))) {
      return;
    }
    a.i.y localy = new a.i.y(paramo);
    Object localObject1 = paramo.v();
    Object localObject3;
    label256:
    do
    {
      if (!((w)localObject1).e()) {
        break;
      }
      localObject2 = ((w)localObject1).d();
      localObject3 = ((e)localObject2).n();
      do
      {
        do
        {
          if (!((a.c.m)localObject3).e()) {
            break label256;
          }
          d locald1 = ((a.c.m)localObject3).a();
          if (i != 0) {
            break;
          }
          if (locald1.g())
          {
            localy.a(locald1);
            if (j != 0) {
              continue;
            }
            if (i == 0) {}
          }
          else
          {
            d locald2 = (d)paramx.get(locald1.f());
            if (j == 0)
            {
              if ((locald2 != null) && (locald2.e() == localObject2))
              {
                double d1 = paramn.getDouble(locald2);
                paramn.a(locald2, d1 + a(locald1));
                paramn.a(locald1, locald2);
                localy.a(locald1);
                if (j != 0) {
                  continue;
                }
                if (i == 0) {}
              }
              else
              {
                paramx.a(locald1.f(), locald1);
              }
            }
            else {
              paramn.a(locald1, a(locald1));
            }
          }
          ((a.c.m)localObject3).f();
        } while (i == 0);
        ((w)localObject1).f();
      } while (j != 0);
    } while (i == 0);
    localObject1 = new HashSet();
    if (j == 0) {
      if (paramo.m() > 500)
      {
        a.a.f.a(paramo, new b_((Set)localObject1), paramn);
        if (j != 0) {
          break label342;
        }
        if (i == 0) {
          break label337;
        }
      }
    }
    a(paramo, new b_((Set)localObject1), paramn);
    label337:
    localy.g();
    label342:
    Object localObject2 = paramo.w();
    do
    {
      if (!((a.c.m)localObject2).e()) {
        break;
      }
      localObject3 = ((a.c.m)localObject2).a();
      if (j == 0)
      {
        if (!((HashSet)localObject1).contains(localObject3))
        {
          if (j != 0) {
            continue;
          }
          if (!((HashSet)localObject1).contains(paramn.get(localObject3))) {}
        }
        else
        {
          paramo.e((d)localObject3);
        }
      }
      else {
        paramab.add(localObject3);
      }
      ((a.c.m)localObject2).f();
    } while (i == 0);
  }
  
  private static void a(q paramq, a.c.n paramn, k paramk)
  {
    int j = f.o;
    int i = f.n;
    if (a.a.l.a(paramq)) {
      return;
    }
    a.i.y localy = new a.i.y(paramq);
    a.c.n localn = a.i.db.b();
    Object localObject1 = paramq.w();
    do
    {
      if (!((a.c.m)localObject1).e()) {
        break;
      }
      localObject2 = ((a.c.m)localObject1).a();
      localn.a(localObject2, paramk.getDouble(localObject2));
      paramn.a(localObject2, false);
      if (j == 0)
      {
        if (((d)localObject2).g())
        {
          localy.a((d)localObject2);
          paramn.a(localObject2, true);
        }
        ((a.c.m)localObject1).f();
      }
    } while (i == 0);
    Object localObject2 = new ab();
    label232:
    do
    {
      for (;;)
      {
        if (!(localObject1 = a.a.f.a(paramq, true)).isEmpty())
        {
          double d1 = 1.7976931348623157E+308D;
          a.c.m localm2 = ((ab)localObject1).l();
          d locald2;
          double d3;
          do
          {
            do
            {
              do
              {
                if (!localm2.e()) {
                  break;
                }
                double d2 = localn.getDouble(localm2.a());
                if (i != 0) {
                  break label232;
                }
                if (d2 < d1) {
                  d1 = d2;
                }
                localm2.f();
              } while (i == 0);
            } while (j != 0);
            localm2 = ((ab)localObject1).l();
            if (!localm2.e()) {
              break;
            }
            if (j != 0) {
              break label347;
            }
            locald2 = localm2.a();
            d3 = localn.getDouble(locald2) - d1;
            localn.a(locald2, d3);
          } while (j != 0);
          if (i != 0) {
            break label342;
          }
          if (i == 0)
          {
            if (d3 < 0.001D)
            {
              localy.a(locald2);
              ((ab)localObject2).add(locald2);
            }
            localm2.f();
            if (i == 0) {
              break;
            }
          }
        }
      }
    } while (j != 0);
    ((ab)localObject2).a(new Comparator()
    {
      private final k val$priorityDP;
      
      public int compare(Object paramAnonymousObject1, Object paramAnonymousObject2)
      {
        return a.i.l.a(-this.val$priorityDP.getDouble(paramAnonymousObject1), -this.val$priorityDP.getDouble(paramAnonymousObject2));
      }
    });
    label342:
    label347:
    a.c.m localm1 = ((ab)localObject2).l();
    do
    {
      if (!localm1.e()) {
        break;
      }
      d locald1 = localm1.a();
      localy.c(locald1);
      if ((j == 0) && (i != 0)) {
        return;
      }
      if (j == 0)
      {
        if (!a.a.l.a(paramq))
        {
          localy.a(locald1);
          paramn.a(locald1, true);
        }
        localm1.f();
      }
    } while (i == 0);
    if (j == 0) {
      localy.g();
    }
  }
  
  protected double a(d paramd)
  {
    return 1.0D;
  }
  
  public int a(q paramq, a.c.x paramx, ab paramab, k paramk)
  {
    this.c = paramk;
    a.i.n.a(this, "Make acyclic");
    a(paramq, paramab);
    a.i.n.a(this, "Assign layers");
    int i = a(paramq, paramx);
    a.i.n.a(this, "done");
    return i;
  }
  
  public void a(o paramo, ab paramab)
  {
    a(paramo, paramab);
  }
  
  public void a(q paramq, ab paramab)
  {
    int j = f.o;
    int i = f.n;
    a.c.n localn = a.i.db.b(new boolean[paramq.l()]);
    a.a.f.b(paramq, localn);
    a.c.m localm = paramq.w();
    do
    {
      if (!localm.e()) {
        break;
      }
      d locald = localm.a();
      if (j == 0)
      {
        if (localn.getBool(locald))
        {
          paramq.e(locald);
          paramab.add(locald);
        }
        localm.f();
      }
    } while (i == 0);
  }
  
  public int a(q paramq, a.c.x paramx)
  {
    return a.a.db.a(paramq, paramx, this.c, null, this.b);
  }
  
  public int b(q paramq, a.c.x paramx)
  {
    int m = f.o;
    int k = f.n;
    bb localbb = a.a.x.b(paramq);
    localbb.j();
    w localw1 = localbb.l();
    do
    {
      do
      {
        if (!localw1.e()) {
          break;
        }
        paramx.a(localw1.d(), 0);
        localw1.f();
      } while (k == 0);
    } while (m != 0);
    int i = 0;
    w localw2 = localbb.l();
    do
    {
      do
      {
        if (!localw2.e()) {
          break;
        }
        e locale = localw2.d();
        int j = paramx.getInt(locale);
        if (m != 0) {
          break label252;
        }
        if (k != 0) {
          break label251;
        }
        if (j > i) {
          i = j;
        }
        a.c.m localm = locale.n();
        do
        {
          do
          {
            if (!localm.e()) {
              break;
            }
            d locald = localm.a();
            if (m != 0) {
              break label252;
            }
            if (k != 0) {
              break label251;
            }
            if (j + this.c.getInt(locald) > paramx.getInt(locald.f())) {
              paramx.a(locald.f(), j + this.c.getInt(locald));
            }
            localm.f();
          } while (k == 0);
          localw2.f();
        } while (m != 0);
      } while (k == 0);
    } while (m != 0);
    label251:
    label252:
    return i + 1;
  }
  
  protected void a(q paramq, a.c.x paramx, int paramInt)
  {
    int n = f.o;
    int m = f.n;
    a.c.z[] arrayOfz = new a.c.z[paramInt + 1];
    int i = 0;
    if (i <= paramInt)
    {
      arrayOfz[i] = new a.c.z();
      i++;
    }
    int j;
    for (;;)
    {
      if ((n != 0) || (m == 0))
      {
        if (m == 0) {
          break;
        }
        if (n == 0)
        {
          w localw = paramq.v();
          do
          {
            do
            {
              if (!localw.e()) {
                break;
              }
              arrayOfz[paramx.getInt(localw.d())].b(localw.d());
              localw.f();
            } while (m == 0);
          } while (n != 0);
          j = paramInt - 1;
        }
      }
    }
    label319:
    label321:
    label324:
    do
    {
      if (j < 0) {
        break;
      }
      a.c.z localz = arrayOfz[j];
      a.c.y localy = localz.h();
      do
      {
        do
        {
          if (!localy.e()) {
            break label324;
          }
          e locale = (e)localy.j();
          if (m != 0) {
            break;
          }
          if (locale.e() != 0)
          {
            int k = paramInt;
            a.c.m localm = locale.n();
            if (localm.e()) {}
            while (n != 0)
            {
              k = Math.min(k, paramx.getInt(localm.a().f()) - this.c.getInt(localm.a()));
              localm.f();
              if (n != 0) {
                break label321;
              }
              if (m != 0) {
                break label319;
              }
              if (m == 0) {
                break;
              }
            }
            if ((n != 0) || ((k > paramx.getInt(locale)) && (locale.e() >= locale.d()))) {
              paramx.a(locale, k);
            }
          }
          localy.f();
        } while (m == 0);
        j--;
      } while (n != 0);
    } while (m == 0);
  }
  
  public void a(o paramo, ac paramac, bc parambc)
  {
    new hc(this).a(paramo, paramac, parambc);
  }
  
  private static final class b_
    implements a.c.n
  {
    private final Set a;
    
    b_(Set paramSet)
    {
      this.a = paramSet;
    }
    
    public Object get(Object paramObject)
    {
      throw new UnsupportedOperationException();
    }
    
    public void a(Object paramObject1, Object paramObject2)
    {
      throw new UnsupportedOperationException();
    }
    
    public void a(Object paramObject, boolean paramBoolean)
    {
      int i = f.o;
      if (i == 0) {
        if (paramBoolean)
        {
          this.a.add(paramObject);
          if ((i == 0) && (f.n == 0)) {
            return;
          }
        }
      }
      this.a.remove(paramObject);
    }
    
    public boolean getBool(Object paramObject)
    {
      return this.a.contains(paramObject);
    }
    
    public void a(Object paramObject, double paramDouble)
    {
      throw new UnsupportedOperationException();
    }
    
    public double getDouble(Object paramObject)
    {
      throw new UnsupportedOperationException();
    }
    
    public void a(Object paramObject, int paramInt)
    {
      throw new UnsupportedOperationException();
    }
    
    public int getInt(Object paramObject)
    {
      throw new UnsupportedOperationException();
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.d.pb

 * JD-Core Version:    0.7.0.1

 */